import org.junit.*;

import static org.junit.Assert.*;

public class NGuessNumberTest {

    @BeforeClass
    public static void setUpBeforeClass() throws Exception {
        System.out.println("@BeforeClass");
    }

    @AfterClass
    public static void tearDownAfterClass() throws Exception {
        System.out.println("@AfterClass");
    }

    @Before
    public void setUp() throws Exception {
        System.out.println("测试开始");
    }

    @After
    public void tearDown() throws Exception {
        System.out.println("测试结束");
    }
    @Test
    public void generateAnswerTest(){
        NGuessNumber nGuessNumber = new NGuessNumber();
        int e[] =nGuessNumber.generateAnswer();

        //判断是不是四个数
        if(e.length==4){
            //判断是不是每个数都不相等
            for(int i=0;i<e.length-1;i++){
                for (int j = e.length-1; j >i; j--) {
                    if (e[i]!=e[j]) {
                        //判断是不都是一位数
                        if(0<e[i]&&e[i]<9) {
                            System.out.println("满足要求");
                        }
                    }
                }
            }
        }
    }

    @Test
    public void getPlayerInputTest() {
        //使用断言检查玩家猜测的数字数量是否为4。
        int numsize = 4;
        NGuessNumber nGuessNumber = new NGuessNumber();
        assertEquals(numsize,nGuessNumber.guesslist.length);
        System.out.println("用户输入的数字数量为4，正确");
    }

    @Test
    public void compareGuessAnswerTest() {
        NGuessNumber nGuessNumber = new NGuessNumber();
        int testguess []= nGuessNumber.guesslist;
        int testnum []= nGuessNumber.generateAnswer();
        int a_num = 0;
        for (int i=0;i<testnum.length;i++){
            for (int j=0;j<testnum.length;j++){
                    if (testnum[i]==testguess[j]){
                        a_num++;
                    }
                }
            }
        String s = a_num+"A"+"A表示存在且位置正确的数字个数";
        System.out.println("测试比较玩家猜测和答案后，返回的提示信息，正确");
        }



}
